revealer: Don't use TRANSITION_NONE for disabled animations
authorTimm Bäder <mail@baedert.org>
Thu, 3 Mar 2016 12:05:14 +0000 (13:05 +0100)
committerTimm Bäder <mail@baedert.org>
Thu, 3 Mar 2016 17:54:09 +0000 (18:54 +0100)
If animations are disabled, the only difference we need to make is that
we don't have to start the transition. Size requests should remain the
same.

https://bugzilla.gnome.org/show_bug.cgi?id=762996

gtk/gtkrevealer.c

index 52ebd26b87b1ec3131134c3b407c7d0e3aa24e42..1df9fd9dd99cf5725a98e7cfa4c543277a9d7ad2 100644 (file)
@@ -289,13 +289,6 @@ static GtkRevealerTransitionType
 effective_transition (GtkRevealer *revealer)
 {
   GtkRevealerPrivate *priv = gtk_revealer_get_instance_private (revealer);
-  gboolean animations_enabled;
-
-  g_object_get (gtk_widget_get_settings (GTK_WIDGET (revealer)),
-                "gtk-enable-animations", &animations_enabled,
-                NULL);
-  if (!animations_enabled)
-    return GTK_REVEALER_TRANSITION_TYPE_NONE;
 
   if (gtk_widget_get_direction (GTK_WIDGET (revealer)) == GTK_TEXT_DIR_RTL)
     {
@@ -339,13 +332,6 @@ gtk_revealer_get_child_allocation (GtkRevealer   *revealer,
           transition == GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT)
         gtk_widget_get_preferred_width_for_height (child, MAX (0, allocation->height - vertical_padding), NULL,
                                                    &child_allocation->width);
-      else if (transition == GTK_REVEALER_TRANSITION_TYPE_NONE)
-        {
-          gtk_widget_get_preferred_width_for_height (child, MAX (0, allocation->height - vertical_padding), NULL,
-                                                     &child_allocation->width);
-          gtk_widget_get_preferred_height_for_width (child, MAX (0, allocation->width - horizontal_padding), NULL,
-                                                     &child_allocation->height);
-        }
       else
         gtk_widget_get_preferred_height_for_width (child, MAX (0, allocation->width - horizontal_padding), NULL,
                                                    &child_allocation->height);
@@ -636,6 +622,7 @@ gtk_revealer_start_animation (GtkRevealer *revealer,
   GtkRevealerPrivate *priv = gtk_revealer_get_instance_private (revealer);
   GtkWidget *widget = GTK_WIDGET (revealer);
   GtkRevealerTransitionType transition;
+  gboolean animations_enabled;
 
   if (priv->target_pos == target)
     return;
@@ -643,10 +630,15 @@ gtk_revealer_start_animation (GtkRevealer *revealer,
   priv->target_pos = target;
   g_object_notify_by_pspec (G_OBJECT (revealer), props[PROP_REVEAL_CHILD]);
 
+  g_object_get (gtk_widget_get_settings (GTK_WIDGET (revealer)),
+                "gtk-enable-animations", &animations_enabled,
+                NULL);
+
   transition = effective_transition (revealer);
   if (gtk_widget_get_mapped (widget) &&
       priv->transition_duration != 0 &&
-      transition != GTK_REVEALER_TRANSITION_TYPE_NONE)
+      transition != GTK_REVEALER_TRANSITION_TYPE_NONE &&
+      animations_enabled)
     {
       priv->source_pos = priv->current_pos;
       priv->start_time = gdk_frame_clock_get_frame_time (gtk_widget_get_frame_clock (widget));